package com.smartplatform.mapper;

import com.smartplatform.dto.DeviceDto;
import com.smartplatform.pojo.SysDevice;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author 咕唧
 * @Date 2022/5/31 10:59
 * @Version 1.0
 */
public interface SysDeviceMapper {
    @Insert("insert into sys_device (device_id,device_name,categy_id) " +
            "values (#{deviceId},#{deviceName},#{categyId})")
    void addDevice(DeviceDto deviceDto);

    @Select("select * from sys_device where device_id =#{deviceId}")
    SysDevice findByDeviceId(String deviceId);

    @Update("update sys_device set status= 1 where device_id =#{deviceId} ")
    void updateSell(String deviceId);

    @Update("update sys_device set status=2, bind_user_id=#{bindUserId} ,scene_id =#{sceneId},bind_time=#{bindTime}" +
            " where device_id =#{deviceId}")
    void bindDevice(SysDevice sysDevice);

    @Select("select * from sys_device where bind_user_id=#{uId}")
    List<SysDevice> findAllByUserId(Long uId);

    @Select("select categy_id from sys_device where device_id=#{deviceId}")
    Long getCategoryIdByDeviceId(String deviceId);

    void updateDevice(SysDevice device);
}
